ARD2  1.00 for Rev B. Hardware
Airbag Reference Demonstrator using MPC5604P
MMA51xx.h File Reference

Establishes a relationship between the SBC and the peculiarities of PSI5 sensors. More...

Go to the source code of this file.

Defines

#define TRUE   (1u)
#define CLEAR   (0u)
#define BITS_IN_NIBBLE   (4u)
#define BITS_IN_BYTE   (8u)
#define BYTES_IN_16   (2u)
#define BYTES_IN_32   (4u)
#define BIT_DEFINITION
#define BIT0   (1u << 0u)
#define BIT1   (1u << 1u)
#define BIT2   (1u << 2u)
#define BIT3   (1u << 3u)
#define BIT4   (1u << 4u)
#define BIT5   (1u << 5u)
#define BIT6   (1u << 6u)
#define BIT7   (1u << 7u)
#define BIT8   (1u << 8u)
#define BIT9   (1u << 9u)
#define BIT10   (1u << 10)
#define BIT11   (1u << 11)
#define BIT12   (1u << 12)
#define BIT13   (1u << 13)
#define BIT14   (1u << 14)
#define BIT15   (1u << 15)
#define BIT16   (1u << 16)
#define BIT17   (1u << 17)
#define BIT18   (1u << 18)
#define BIT19   (1u << 19)
#define BIT20   (1u << 20)
#define BIT21   (1u << 21)
#define BIT22   (1u << 22)
#define BIT23   (1u << 23)
#define BIT24   (1u << 24)
#define BIT25   (1u << 25)
#define BIT26   (1u << 26)
#define BIT27   (1u << 27)
#define BIT28   (1u << 28)
#define BIT29   (1u << 29)
#define BIT30   (1u << 30)
#define BIT31   (1u << 31)
#define N_ELEMENTS(X)   (sizeof(X)/sizeof(*(X)))
#define MMA5100_SENSOR_READY_STATUS   BIT15
#define MMA5100_SENSOR_READY_UNLOCKED_STATUS   (MMA5100_SENSOR_READY_STATUS | BIT14)
#define MMA5100_SENSOR_DEFECT_STATUS   BIT13
#define MMA5100_SENSOR_BUSY_STATUS   BIT12
#define MMA5100_COMMAND_NOT_RECOGNIZED   BIT11
#define MMA5100_SENSOR_DEFECT   ((uint16_t)0x1F4)
#define MMA5100_SENSOR_BUSY   ((uint16_t)0x1e8)
#define MMA5100_SENSOR_READY   ((uint16_t)0x1e7)
#define MMA5100_SENSOR_READY_UNLOCKED   ((uint16_t)0x1e6)
#define MMA5100_DATA_INDICATOR   ((uint16_t)0x10u)
#define MMA5100_CONTENTS_MASK   ((uint16_t)0x0Fu)
#define MMA5100_N_REGISTERS   ((uint8_t)19u)
#define MMA5100_UL_FOR_DATA   ((uint16_t)0x220u)
#define MMA5100_LL_FOR_DATA   ((uint16_t)0x1FFu)
#define MMA5100_UL_FOR_STATUS   ((uint16_t)0x200u)
#define MMA5100_LL_FOR_STATUS   ((uint16_t)0x1E0u)

Enumerations

enum  MMA5100_REGISTER_INDEX {
  PROTOCOL = 0, N_DATA_BLOCKS, MANUFACTURER, SENSOR_TYPE,
  AXIS, RANGE, DEVCFG2, PRODUCT_REVISION,
  DEVCFG6, PROD_DATE_1, PROD_DATE_2, SN0,
  SN1, SN2, SN3, INIT_RAW_OFFSET,
  COMBINED_OFFSET_SELF_TEST, AVG_SELF_TEST, DEVCFG1
}
enum  MMA5100_RAW_DATA_INDEX {
  MMA5100_D1 = 0, MMA5100_D2, MMA5100_D3, MMA5100_D4,
  MMA5100_D5, MMA5100_D6, MMA5100_D7, MMA5100_D8,
  MMA5100_D9, MMA5100_D10, MMA5100_D11, MMA5100_D12,
  MMA5100_D13, MMA5100_D14, MMA5100_D15, MMA5100_D16,
  MMA5100_D17, MMA5100_D18, MMA5100_D19, MMA5100_D20,
  MMA5100_D21, MMA5100_D22, MMA5100_D23, MMA5100_D24,
  MMA5100_D25, MMA5100_D26, MMA5100_D27, MMA5100_D28,
  MMA5100_D29, MMA5100_D30, MMA5100_D31, MMA5100_D32
}

Functions

uint16_t u16fnMMA5100TreatData (uint16_t *pu16SatData, uint8_t *pu8ResultArray, uint8_t *pu8CurrentIndex, uint8_t *pu8IndexAdder, uint32_t *pu32AlreadyWritten)
 As PSI5 satellite data comes in, this function treates the currently received word and gets ready to treat it. It shall be called several times in order to take care of all downloaded data.

Detailed Description

Establishes a relationship between the SBC and the peculiarities of PSI5 sensors.

Copyright (C) 2011 Freescale Semiconductor Freescale Confidential Proprietary

Author:
Freescale Semiconductor
SASD Automotive
r11515
Version:
Date:
Warning:
(If needed)

History:


Function Documentation

uint16_t u16fnMMA5100TreatData ( uint16_t *  pu16SatData,
uint8_t *  pu8ResultArray,
uint8_t *  pu8CurrentIndex,
uint8_t *  pu8IndexAdder,
uint32_t *  pu32AlreadyWritten 
)

As PSI5 satellite data comes in, this function treates the currently received word and gets ready to treat it. It shall be called several times in order to take care of all downloaded data.

Parameters:
pu16SatData,:Pointer to the current word that has been received.
pu8ResultArray,:Pointer to a memory location that shall contain an array where to store all registers; a virtual memory map, if you will.
pu8CurrentIndex,:Pointer to a memory location that keeps track of the current index for the next piece of data.
pu8IndexAdder,:Pointer to a memory location that shall remember if we have already downloaded the first half of the register table, and if we have, writes to it to generate an index offset used in the pu8ResultArray.
pu32AlreadyWritten,:Pointer to a mask that keeps track if an existing register has already been written or not.
Returns:
Status based on whether the received data has been: Ok (CLEAR); MMA5100_COMMAND_NOT_RECOGNIZED; MMA5100_SENSOR_READY_UNLOCKED_STATUS; MMA5100_SENSOR_READY_STATUS; MMA5100_SENSOR_BUSY_STATUS; MMA5100_SENSOR_DEFECT_STATUS